<?php
	$css_list[0]['url'] = './tpl/css/article.css';
?>
<!--{template inc/header_n}-->

<div class="main_warp">
    <div class="inventory">
        <!--{template inc/list/list_menu}-->

        <div class="i_righter">
            <div class="i_list" id="ivtList">
                <div class="i_tt" id="tip">{if $iscomplete}已全部完成{else}未全部完成{/if}</div>
                <ul>
                    {loop $subcates $subcate}
                    <li>
                        <a href="javascript:;" class="j_a"><span class="j_s{if in_array($subcate['cate_id'],$cateids)} j_s_yes{/if}">{if in_array($subcate['cate_id'],$cateids)}已完成{else}未完成{/if}</span>{$subcate['cate_name']}</a>
                        <div class="j_info">
                            {loop $subcate['format_links'] $link}
                            {$link}<br/>
                            {/loop}
                            {if !in_array($subcate['cate_id'],$cateids)}<a id="doread_{$subcate['cate_id']}" name="doread" href="javascript:;" onclick="doread({$subcate['cate_id']})" class="j_btn">完成</a>{/if}
                            <br class="g_clear" />
                        </div>
                    </li>
                    {/loop}
                </ul>
            </div>
        </div>
        <br class="g_clear" />

    </div>

</div>

<!--{template inc/footer}-->
<script type="text/javascript">
$("#ivtList .j_a").click( function () {
    if( $(this).next('.j_info').is(":visible") ){
        $(this).next('.j_info').hide();
        $(this).children('.j_s').show();
    }else{
        $("#ivtList .j_info").hide();
        $("#ivtList .j_s").show();
        $(this).next('.j_info').show();
        $(this).children('.j_s').hide();
    }
});

$("#ivtList .j_btn").click( function () {
    $("#ivtList .j_info").hide();
    $(this).parent().parent().find('.j_s').show().addClass("j_s_yes").html("已完成");
});

$("#ivtList li:eq(0) .j_info").show();

function doread(id) {
    $.get('/list.php?action=doread&id='+id, function(s){
        $('#doread_'+id).remove();
        if($('[name="doread"]').length == 0) {
            $('#tip').html('已全部完成');
        }
    })
}
</script>